//
//  swift
//  Charts
//
//  Created by 尹琼 on 2022/10/26.
//

import UIKit
import SwiftDate


public let languageCode = Locale.current.languageCode!

public let myLocal = (languageCode == "ar" || languageCode == "hi" || languageCode == "ps" || languageCode == "he") ? Locale(identifier: "en_US"): Locale.current


public func getCurrentLanguage() -> Locales {
    
    guard let locales = Locales(rawValue: languageCode) else {
        return Locales.current
    }
    return locales
}

public func getPreferredLanguages() -> String {
    let languaes = Locale.preferredLanguages
    
    if languaes.count > 0{
        let languageArray = languaes.first!.components(separatedBy: "-")
        if languageArray.count > 0{
            return languageArray.first!
        }else{
            return languageCode
        }
    } else {
        return languageCode
    }
}

public func viewIsContrast() -> Bool{
    var isContrast = false
    let language = (Bundle.main.preferredLocalizations.first! as NSString)
    if language == "ar" || language == "ps" || language == "ps-AF" || language == "he"{
        isContrast = true
    }
    return isContrast
}

